using Unity.VisualScripting;

namespace LS.UGFUnits
{
    public class LoadScene: SceneUnit
    {
        [DoNotSerialize]
        public ValueInput AssetName { get; private set; }

        [DoNotSerialize]
        public ValueInput Priority { get; private set; }
        
        [DoNotSerialize]
        public ValueInput UserData { get; private set; }
        protected override void Definition()
        {
            base.Definition();
            AssetName = ValueInput<string>(nameof(AssetName), string.Empty);
            Priority = ValueInput<int>(nameof(Priority), 0);
            UserData = ValueInput<object>(nameof(UserData), 0);
            Requirement(AssetName, Input);
            Requirement(Priority, Input);
            Requirement(UserData, Input);
        }

        protected override ControlOutput In(Flow flow)
        {
            string assetName = flow.GetValue<string>(AssetName);
            int priority = flow.GetValue<int>(Priority);
            object userData = flow.GetValue<object>(UserData);
            Target?.LoadScene(assetName, priority, userData);
            return base.In(flow);
        }
    }
}